﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Configuration.cs" company="Rolosoft Ltd">
//   © Rolosoft Ltd
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

#region License

// Copyright 2013 Rolosoft Ltd
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

namespace Rsft.Net.Dns.Entities
{
    #region Usings

    using System.Collections.Generic;
    using System.Net;

    using Rsft.Net.Dns.Helpers;

    #endregion

    /// <summary>
    ///     The configuration.
    /// </summary>
    public sealed class DnsConfiguration
    {
        #region Constants

        /// <summary>
        ///     The default recursion
        /// </summary>
        private const bool DefaultRecursion = true;

        /// <summary>
        ///     The default retries
        /// </summary>
        private const int DefaultRetries = 3;

        /// <summary>
        ///     The default timeout in milliseconds.
        /// </summary>
        private const int DefaultTimeout = 2000;

        /// <summary>
        ///     The default transport type.
        /// </summary>
        private const TransportType DefaultTransportType = TransportType.Udp;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="DnsConfiguration"/> class.
        /// </summary>
        public DnsConfiguration()
        {
            this.DnsServers = new List<IPEndPoint>();
            this.DnsServers.AddRange(DnsServer.LocalDefaultDnsServers);
            this.DnsTimeout = DefaultTimeout;
            this.Retries = DefaultRetries;
            this.UseRecursion = DefaultRecursion;
            this.TransportType = DefaultTransportType;
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///     Gets or sets the DNS servers to use.
        /// </summary>
        /// <value>
        ///     The DNS servers.
        /// </value>
        /// <remarks>
        ///     Default is configured DNS servers for local machine.
        /// </remarks>
        public List<IPEndPoint> DnsServers { get; set; }

        /// <summary>
        ///     Gets or sets the DNS timeout.
        /// </summary>
        /// <value>
        ///     The DNS timeout.
        /// </value>
        /// <remarks>
        ///     Default is 2000ms
        /// </remarks>
        public int DnsTimeout { get; set; }

        /// <summary>
        ///     Gets or sets the retries.
        /// </summary>
        /// <value>
        ///     The retries.
        /// </value>
        /// <remarks>
        ///     Default is 3
        /// </remarks>
        public int Retries { get; set; }

        /// <summary>
        ///     Gets or sets the type of the transport.
        /// </summary>
        /// <value>
        ///     The type of the transport.
        /// </value>
        /// <remarks>
        /// Default is TransportType.Udp
        /// </remarks>
        public TransportType TransportType { get; set; }

        /// <summary>
        ///     Gets or sets a value indicating whether to use recursive lookups.
        /// </summary>
        /// <remarks>
        ///     Default = true
        /// </remarks>
        public bool UseRecursion { get; set; }

        #endregion
    }
}